#ifdef WX_PRECOMP
#include "wx_pch.h"
#else
#include <wx/wx.h>
#endif //WX_PRECOMP

#include "custom_events.h"

DEFINE_LOCAL_EVENT_TYPE(wxEVT_DESIGN_CHANGED)
DEFINE_LOCAL_EVENT_TYPE(wxEVT_TREE_SELECT_COMPONENT)
DEFINE_LOCAL_EVENT_TYPE(wxEVT_CHANGE_CELL_COMBINATION)
DEFINE_LOCAL_EVENT_TYPE(wxEVT_CHANGE_CELL_SELECTION)
DEFINE_LOCAL_EVENT_TYPE(wxEVT_CHANGE_CELL_LEVEL)
DEFINE_LOCAL_EVENT_TYPE(wxEVT_WANT_INSERT_COMPONENT)

void CustomEvent::NotifyAboutFilterChange(wxEvtHandler* handler, int ownerId, int newFilter)
{
  wxCommandEvent event(wxEVT_CHANGE_CELL_COMBINATION, ownerId);
  event.SetInt(newFilter);
  handler->ProcessEvent(event);
}

void CustomEvent::NotifyAboutSelectComponent(wxEvtHandler* handler, int ownerId, int raceID, int componentID)
{
  wxCommandEvent event(wxEVT_TREE_SELECT_COMPONENT, ownerId);
  event.SetInt(componentID);
  event.SetExtraLong(raceID);
  handler->ProcessEvent(event);
}

void CustomEvent::NotifyAboutDesignChanged(wxEvtHandler* handler, int ownerId)
{
  wxCommandEvent event(wxEVT_DESIGN_CHANGED, ownerId);
  handler->ProcessEvent(event);
}

void CustomEvent::NotifyAboutItemSelection(wxEvtHandler* handler, int ownerId, CellDataItem* item)
{
  wxCommandEvent event(wxEVT_CHANGE_CELL_SELECTION, ownerId);
  event.SetClientData(item);
  handler->ProcessEvent(event);
}

void CustomEvent::NotifyAboutWantComponentLevelChange(wxEvtHandler* handler, int ownerId, int newLevel)
{
  wxCommandEvent event(wxEVT_CHANGE_CELL_LEVEL, ownerId);
  event.SetInt(newLevel);
  handler->AddPendingEvent(event);
}

void CustomEvent::NotifyAboutWantInstallComponent(wxEvtHandler* handler, int ownerId, int raceID, int componentID)
{
  wxCommandEvent event(wxEVT_WANT_INSERT_COMPONENT, ownerId);
  event.SetInt(componentID);
  event.SetExtraLong(raceID);
  handler->ProcessEvent(event);
}
